﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>修改患者信息</title>
    <link href="~/BootstrapS/css/plugins/iCheck/custom.css" rel="stylesheet" />
    <link href="~/BootstrapS/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="~/vue/axios.min.js"></script>
    <script src="~/vue/qs.min.js"></script>
    <script src="~/vue/vue.min.js"></script>
    <script src="~/BootstrapS/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/BootstrapS/js/plugins/sweetalert/sweetalert.min.js"></script>

</head>

<body>
    <div id="updiv">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" v-on:click="location.reload()" aria-hidden="true" style="font-size:30px">
                &times;
            </button>
            <h3 class="modal-title" id="myModalLabel">修改患者信息</h3>
        </div>
        <div>
            <div style="width:45%;float:left;margin-left:20px;margin-top:15px">
                患者姓名

                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" style="width:240px" placeholder="请输入患者姓名" v-model="patient.patient_Name">
                <br /><br />
                患者年龄
                <input type="search" class="form-control input-sm" v-model="patient.patient_Age" aria-controls="DataTables_Table_0" style="width:240px" placeholder="请输入病人年龄">
                <br /><br />
                出生日期<br />
                
                <input id="hello" class="laydate-icon form-control layer-date" v-model="patient.patient_Birthday" v-bind:disabled="disabled">
                <br />
                <br />
                邮箱地址
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" style="width:240px" placeholder="请输入邮箱地址" v-model="patient.patient_Email">
                <br />
                <br />
            </div>
            <div style="width:45%;float:right;margin-left:10px;margin-top:15px">
                身份证号
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" style="width:240px" placeholder="请输入身份证号" v-model="patient.patient_IDnumber">
                <br /><br />
                患者性别
                <br /><br />
                <input type="radio" id="sex1" name="sexname" v-model="patient.patient_Sex" value="0">
                <label for="0">男</label>
                <input type="radio" id="sex2" name="sexname" v-model="patient.patient_Sex" style="margin-left:20px" value="1">
                <label for="1">女</label>
                <br /><br />
                联系方式
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" style="width:240px" placeholder="请输入手机号" v-model="patient.patient_IPhone">
                <br /><br />
                选择就诊科室<br />
                <select id="Selecttab" class="btn btn-outline btn-success" style="width:200px" v-model="patient.outpatient_Id">
                    <option v-bind:value="0">请选择就诊科室</option>
                    <option v-for="item in info" v-bind:value="item.outpatient_Id">{{item.outpatient_Name}}</option>
                </select>
                <br /><br />
            </div>
            <div style="width:90%;float:left;margin-left:20px">
                家庭住址<textarea id="TextArea1" class="form-control input-sm" aria-controls="DataTables_Table_0" rows="6" cols="15" placeholder="请输入其他备注信息" v-model="patient.patient_Home"></textarea>
                <br /><br />
            </div>
        </div>
        <div class="modal-footer">
            <div style="float:right">
                <button type="button" class="btn btn-outline btn-default" v-on:click="location.reload()" data-dismiss="modal">
                    退出
                </button>
                <button type="button" v-on:click="updatepatient" class="btn btn-outline btn-warning">提交</button>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    var pid = sessionStorage["pid"];

    new Vue({
        el: '#updiv',
        data() {
            return {
                info: null,
                patient: null,
                disabled: true
            }
        },
        mounted() {
            function getout() {
                return axios
                    .get('/Patient/GetOutpatient');
            }
            function getpat() {
                return axios.get('/Patient/GetPatientById', { params: { pid: pid } });
            }
            axios.all([getout(), getpat()])
                .then(axios.spread((outpat, patbyid) => {
                    this.info = outpat.data;
                    this.patient = patbyid.data;
                }))
        },
        methods: {
            updatepatient: function () {
                var obj = {
                    Patient_Id: this.patient.patient_Id,
                    Patient_Name: this.patient.patient_Name,
                    Patient_Age: this.patient.patient_Age,
                    Patient_Sex: this.patient.patient_Sex,
                    Outpatient_Id: this.patient.outpatient_Id,
                    Patient_IDnumber: this.patient.patient_IDnumber,
                    Patient_Birthday: this.patient.patient_Birthday,
                    Patient_IPhone: this.patient.patient_IPhone,
                    Patient_Email: this.patient.patient_Email,
                    Patient_Home: this.patient.patient_Home
                }
                axios
                    .post("/Patient/Updatepat", window.Qs.stringify(obj))
                    .then(function (response) {
                        if (response.data.success == true) {
                            swal({
                                title: response.data.message,
                                text: "",
                                type: "success",
                                confirmButtonText: "确定",
                                closeOnConfirm: false
                            }, function () {
                                location.reload();
                            })
                        }
                        else {
                            swal({
                                title: response.data.message,
                                text: "",
                                type: "warning",
                                confirmButtonText: "确定",
                                closeOnConfirm: false
                            })
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    })
            }
        }
    })
</script>